package com.ruoyi.user.controller;

import com.ruoyi.common.core.domain.*;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.user.service.TbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 咸鱼
 * @version 1.0
 * @description: TODO
 * @date 2023/1/12 14:03
 */
@RequestMapping("/user")
@RestController
public class TbUserController {
    @Autowired
    private TbUserService tbUserService;

    /*
    根据Id获取用户
     */
    @PostMapping("/getUserById")
    public R<UserVo> getUser(@RequestBody IdVo idVo){
        return tbUserService.getUserById(idVo);
    }

    @PostMapping("/selectAllUserByCondition")
    public AjaxResult selectAllUserByCondition(@RequestBody UserQueryCondition userQueryCondition){
        return tbUserService.selectAllUserByCondition(userQueryCondition);
    }

    @PostMapping("/addUser")
    public R addUser(@RequestBody UserVo userVo){
        return tbUserService.addUser(userVo);
    }

    @PostMapping("/deleteUserById")
    public R deleteUser(@RequestBody IdVo idVo){
        return tbUserService.deleteUserById(idVo);
    }

    @PostMapping("/updateUserForCondition")
    public R updateUserForCondition(@RequestBody UserUpdateCondition userUpdateCondition){
        return tbUserService.updateUserForCondition(userUpdateCondition);
    }

    @PostMapping("/verifyCodeLogin")
    public R verifyCodeLogin(@RequestBody LoginVo loginVo){
        return tbUserService.verifyCodeLogin(loginVo);
    }
}
